﻿using Core.Domain.Entities;
using Core.Migrations.Extensions;
using FluentMigrator;

namespace Infrastructure.Persistence.Migrations.UserProfiles;

[Migration(202511081157)]
public class CreateTable : ForwardOnlyMigration
{
    public override void Up()
    {
        MigrationExpressions.CreateTableAuditableEntityFor<UserProfile>(Create, SchemaNames.Identity);

        // 1️⃣ 创建 UserPreferences 表
        Create.Table("UserPreferences")
            .InSchema(SchemaNames.Identity)
            .WithColumn("UserProfileId").AsGuid().PrimaryKey().NotNullable()
                .WithColumnDescription("所属 UserProfile 的 Id，用于逻辑关联")
            .WithColumn("Key").AsString(100).NotNullable()
                .WithColumnDescription("偏好项的唯一标识键，例如 '系统消息'")
            .WithColumn("Value").AsString(int.MaxValue).NotNullable()
                .WithColumnDescription("偏好值，JSON 序列化存储")
            .WithColumn("ValueType").AsString(200).Nullable()
                .WithColumnDescription("序列化值的类型信息，用于调试或反序列化")
            .WithColumn("Description").AsString(500).Nullable()
                .WithColumnDescription("偏好项的说明或描述");
    }
}
